import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class DrawPanel implements ActionListener{
	int x = 70,y = 70;

	public static void main(String[] args) {
		DrawPanel draw = new DrawPanel();
		draw.go();
	}

	MyDrawPanel drawpanel = new MyDrawPanel();

	public void go(){
		JFrame frame = new JFrame();
		JButton button = new JButton("Go!");
		
		frame.getContentPane().add(drawpanel);
		frame.getContentPane().add(BorderLayout.EAST,button);
		button.addActionListener(this);
		frame.setSize(400,300);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setVisible(true);	
		
	}

	public void actionPerformed(ActionEvent event){
		for(int i =0; i<300;i++){
			x++;
			y++;
try{
				Thread.sleep(10);
			}catch(Exception e){}
			drawpanel.repaint();

			

		}	
	} 
	class MyDrawPanel extends JPanel{

		public void paintComponent(Graphics g){
			g.setColor(Color.white);
			g.fillRect(0,0,this.getWidth(),this.getHeight());

			g.setColor(Color.red);
			g.fillOval(x,y,40,40);

		}
	}
}